<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>用户举报</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"><!-- 确保适当的绘制和触屏缩放 -->
    <link rel="stylesheet" href="{$url_css}/bootstrap.min.css" type="text/css">
    <script type="text/javascript" src="{$url_js}jquery-1.12.0.min.js"></script>
</head>
<body>
<div class="container" style="width:96%">
    <form action="?do=default" method="get">
        <table class="table table-bordered table-striped" align="center">
            <tr>
                <td colspan="5">查询条件</td>
            </tr>
            <tr>
                <td class="form-group col-xs-2">
                    <div class="input-group">
                        <div class="input-group-addon">用户ID</div>
                        <input type="text" class="form-control" name="user_id" placeholder="用户ID" value="{if $user_id}{$user_id}{/if}">
                    </div>
                </td>
                <td class="form-group col-xs-2">
                    <div class="input-group">
                        <div class="input-group-addon">条目ID</div>
                        <input type="text" class="form-control" name="itemid" placeholder="文章ID" value="{if $itemid}{$itemid}{/if}" onkeyup="this.value=this.value.replace(/[^\d]/g,'')">
                    </div>
                </td>
                <td class="form-group col-xs-2">
                    <div class="input-group">
                        <div class="input-group-addon">反馈类型</div>
                            <select class="form-control" name="itemtype">
                                <option>请选择</option>
                                {foreach $type as $k => $v}
                                <option value="{$k}" {if $itemtype === $k}selected{/if}>{$v}</option>
                                {/foreach}
                            </select>
                    </div>
                </td>
                <td class="form-group col-xs-2">
                    <div class="input-group">
                        <div class="input-group-addon">反馈状态</div>
                            <select class="form-control" name="status">
                                <option>请选择</option>
                                <option value="1" {if $status == 1}selected{/if}>待处理</option>
                                <option value="2" {if $status == 2}selected{/if}>不解决</option>
                                <option value="3" {if $status == 3}selected{/if}>已解决</option>
                            </select>
                    </div>
                </td>
                <td class="form-group col-xs-2" colspan="3">
                    <input type="submit" value="搜索" class="btn btn-primary" />
                </td>
            </tr>
        </table>
    </form>

    <table class="table table-bordered table-striped" align="center">
        <tbody>
        <tr>
            <td colspan="10"><strong>操作记录总数：{$total} 条</strong></td>
        </tr>
        <tr align="center">
            <td width="3%">用户ID</td>
            <td width="4%">反馈类型</td>
            <td width="4%">条目ID</td>
            <td width="4%">条目类型</td>
            <td width="6%">条目标题</td>
            <td width="10%">反馈内容</td>
            <td width="4%">举报状态</td>
            <td width="6%">反馈时间</td>
            <td width="10%">操作</td>
        </tr>
        {if !empty($data)}
            {foreach $data as $v}
                <tr align="center">
                    <td id="id{$v.ReportId}">{$v.UserId}</td>
                    <td>{$type[$v.Type]}</td>
                    <td>{$v.ItemId}</td>
                    <td>{$ItemType[$v['ItemType']]|html}</td>
                    <td>
                        {if $v['ItemType'] == 1}
                            <span title="{$title[$v['ItemId']]|html}">{$title[$v['ItemId']]|truncate:10:"...":true|html}</span>
                            {elseif $v['ItemType'] ==2}
                            <span title="{$title[$v['ItemId']]|html}">{$title[$v['ItemId']]|truncate:10:"...":true|html}</span>
                        {/if}
                    </td>
                    <td><span title="{$v.Content|html}">{$v.Content|truncate:20:"...":true|html}</span></td>
                    <td id="status_{$v['ReportId']}">
                        {if $v['Status']==1}
                            <span style="color: #FFA500">{$Status[$v['Status']]|html}</span>
                        {elseif $v['Status']==2}
                            <span style="color: #4169E1">{$Status[$v['Status']]|html}</span>
                        {elseif $v['Status']==3}
                            <span style="color: #228B22">{$Status[$v['Status']]|html}</span>
                        {/if}
                    </td>
                    <td>{$v.CreateTime}</td>
                    <td>
                        <button type="button" class="btn btn-warning" id="a{$v['ReportId']}" {if $v['Status'] == 1}style="display: none"{/if} onclick="showHidden({$v['ReportId']}, 1)">待解决</button>
                        <button type="button" class="btn btn-info" id="b{$v['ReportId']}" {if $v['Status'] == 2}style="display: none"{/if} onclick="showHidden({$v['ReportId']}, 2)">不解决</button>
                        <button type="button" class="btn btn-success" id="c{$v['ReportId']}" {if $v['Status'] == 3}style="display: none"{/if} onclick="showHidden({$v['ReportId']}, 3)">已解决</button>
                    </td>
                </tr>
            {/foreach}
        {/if}
        {if $pagination != ''}
            <tr><td colspan="16" align="right">{$pagination}</td></tr>
        {/if}
        </tbody>
    </table>
</div>

{literal}
    <script>
        function showHidden(id, type) {
            var tit;
            if (type == 1) {
                tit = '待解决';
            } else if(type == 2) {
                tit = '不解决';
            } else {
                tit = '已解决';
            }
            top.swal({
                title: "您确定要" + tit + "此事件？",
                type: "warning",
                showCancelButton: true,
                closeOnConfirm: false,
                confirmButtonText: "是的，我要" + tit,
                cancelButtonText: "取消",
                confirmButtonColor: "#ec6c62"
            }, function () {
                $.post("?do=UpdateStatus",{'id':id,'status':type}, function (data) {
                    if (data.type == 'success') {
                        top.sweetAlert('操作成功', '', data.type);
                        if (type == 1) {
                            $('#a' + id).css('display', 'none');
                            $('#b' + id).css('display', '');
                            $('#c' + id).css('display', '');
                            $('#status_'+id).html('<span style="color: #FFA500">待解决</span>');
                        } else if(type == 2) {
                            $('#b' + id).css('display', 'none');
                            $('#a' + id).css('display', '');
                            $('#c' + id).css('display', '');
                            {$('#status_'+id).html('<span style="color: #4169E1">不解决</span>')};
                        } else {
                            $('#c' + id).css('display', 'none');
                            $('#b' + id).css('display', '');
                            $('#a' + id).css('display', '');
                            $('#status_'+id).html('<span style="color: #228B22">已解决</span>');
                        }
                    } else {
                        top.sweetAlert('操作失败', '', data.type);
                    }
                },'json');
            });
        }

    </script>
{/literal}

</body>
</html>
    